package cn.edu.xmu.oomall.customer.dao.bo;


import cn.edu.xmu.javaee.core.aop.CopyFrom;
import cn.edu.xmu.javaee.core.model.bo.OOMallObject;
import cn.edu.xmu.javaee.core.model.dto.UserDto;
import cn.edu.xmu.oomall.customer.controller.dto.CustomerDto;
import cn.edu.xmu.oomall.customer.dao.CustomerDao;
import cn.edu.xmu.oomall.customer.mapper.po.CustomerPo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.time.LocalDateTime;

@NoArgsConstructor
@AllArgsConstructor
@ToString(callSuper = true, doNotUseGetters = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
@CopyFrom({CustomerPo.class, CustomerDto.class})
public class Customer extends OOMallObject {

    private final static Logger logger = LoggerFactory.getLogger(Customer.class);

    //禁用
    @ToString.Exclude
    @JsonIgnore
    public static final Byte VALID = 0;
    //有效
    @ToString.Exclude
    @JsonIgnore
    public static final Byte BAN = 1;
    //删除
    @ToString.Exclude
    @JsonIgnore
    public static final Byte DELETE = 2;

    private String userName;

    private String password;

    private String name;

    private Long point;

    private String mobile;

    private Byte invalid;

    private byte beDeleted;

    private CustomerDao customerDao;

    public void setCustomerDao(CustomerDao customerDao) {
        this.customerDao = customerDao;
    }

    public byte getBeDeleted() {
        return beDeleted;
    }

    public void setBeDeleted(byte beDeleted) {
        this.beDeleted = beDeleted;
    }

    public Byte getInvalid() {
        return invalid;
    }

    public void setInvalid(Byte invalid) {
        this.invalid = invalid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Long getPoint() {
        return point;
    }

    public void setPoint(Long point) {
        this.point = point;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public void setGmtCreate(LocalDateTime gmtCreate) {
        this.gmtCreate = gmtCreate;
    }

    public void setGmtModified(LocalDateTime gmtModified) {
        this.gmtModified = gmtModified;
    }

    public CustomerDao getCustomerDao() {
        return customerDao;
    }

    public void updateCustomerBanStatus(UserDto user) {
        this.invalid = BAN;
        customerDao.save(this, user);
    }

    public void updateCustomerReleaseStatus(UserDto user) {
        this.invalid = VALID;
        customerDao.save(this, user);
    }
}
